package lesosn03;

public class TestMain2 {
    public static void main(String[] args) {
        // 调用有参数构造方法，初始化属性
        Student stu1 = new Student("Tom", 10);
        // lesosn03.Student@3c679bde
        // Student 覆盖toString之后  多态了 Student{name='Tom', age=10}
        System.out.println(stu1);
        // println(Object obj)
        // (obj == null) ? "null" : obj.toString();

        //   Object类的toString() {
        //        return getClass().getName() + "@" + Integer.toHexString(hashCode());
        //    }

        Integer a1 = 1;
        aaaaaaaaa(a1);
        Object a = new A();
        // 不覆盖toString lesosn03.A@1540e19d
        // 覆盖toString   A类覆盖了toString方法
        aaaaaaaaa(a);
    }
    public static void aaaaaaaaa(Object obj) { // Object obj = a1
        System.out.println(obj.toString());   // Integer.toStirng() --> new String(1);
    }
}
class A extends Object{
    @Override
    public String toString() {
        return "A类覆盖了toString方法";
    }
}
